package com.scf.fruit.useraddress.impl;

import com.scf.fruit.useraddress.UserAddressDto;
import com.scf.fruit.useraddress.UserAddressService;
import com.scf.fruit.useraddress.dao.UserAddressMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author : 孙超飞
 * @title :
 * @description :
 * @copyright :
 * @date : 2018-05-18 16:08
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Resource
    private UserAddressMapper userAddressMapper;
    @Override
    public boolean saveAddress(UserAddressDto dto) {
        dto.setCreateTime(new Date());
        return userAddressMapper.insertSelective(dto)>0;
    }

    @Override
    public List<UserAddressDto> queryUserAddress(UserAddressDto dto) {
        return userAddressMapper.select(dto);
    }

    @Override
    public List<UserAddressDto> queryByUserId(Long userId) {
        UserAddressDto dto=new UserAddressDto();
        dto.setUserId(userId);
        return userAddressMapper.select(dto);
    }

    @Override
    public List<UserAddressDto> queryUserAddressAll() {
        return userAddressMapper.selectAll();
    }
}
